package com.huawei.appmarket.service.store.awk.card;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.ui.css.CSSView;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.service.appdetail.bean.detail.DetailTextListBean;
import com.huawei.appmarket.service.appdetail.bean.detail.DetailTextListBean.TextListItem;
import com.huawei.appmarket.service.settings.view.widget.EnterLayout;
import com.huawei.hms.support.api.entity.hwid.HwIDConstant.ACTION;
import java.util.List;
import o.cgz;
import o.chz;
import o.ckt;
import o.Logger;
import o.dof;
import o.CollectCheck;
import o.ewm.e;
import o.ewm.j;

public class DetailTextListGeneralCard extends BaseDistCard implements OnClickListener {
    private DetailTextListBean ˋ;
    private LinearLayout ॱॱ;

    public /* synthetic */ cgz ˏ(View view) {
        return ˎ(view);
    }

    public DetailTextListGeneralCard(Context context) {
        super(context);
    }

    public DetailTextListGeneralCard ˎ(View view) {
        this.ॱॱ = (LinearLayout) view.findViewById(j.ˍˏ);
        ʽ(view);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        this.ˋ = (DetailTextListBean) cardBean;
        if (this.ˋ != null && !CollectCheck.isEmpty(this.ˋ.ॱ()) && !dof.ॱ(this.ˋ.ˊ())) {
            List ॱ = this.ˋ.ॱ();
            int size = ॱ.size();
            for (int i = 0; i < size; i++) {
                TextListItem textListItem = (TextListItem) ॱ.get(i);
                int ॱ2 = textListItem.ॱ();
                if (!(ॱ2 == 2 || ॱ2 == 3)) {
                    EnterLayout enterLayout;
                    if (i > this.ॱॱ.getChildCount() - 1) {
                        enterLayout = new EnterLayout(this.ॱॱ.getContext());
                        enterLayout.setId(j.ʽٴ + i);
                        enterLayout.setBackgroundResource(e.ᐨ);
                        this.ॱॱ.addView(enterLayout);
                    } else {
                        enterLayout = (EnterLayout) this.ॱॱ.getChildAt(i);
                    }
                    enterLayout.setTitle(textListItem.ˋ());
                    if (dof.ॱ(textListItem.ˏ()) || textListItem.ˊ() == 1) {
                        enterLayout.setMemoVisibility(8);
                    } else {
                        enterLayout.setMemoVisibility(0);
                        enterLayout.setMemo(textListItem.ˏ());
                    }
                    if (ॱ2 == 0) {
                        enterLayout.setArrorVisibility(8);
                    } else {
                        enterLayout.setArrorVisibility(0);
                        enterLayout.setOnClickListener(new ckt(this));
                    }
                }
            }
        }
    }

    public void onClick(View view) {
        if (view != null) {
            int size = this.ˋ.ॱ().size();
            int id = view.getId() - j.ʽٴ;
            if (id >= 0 && id < size) {
                TextListItem textListItem = (TextListItem) this.ˋ.ॱ().get(id);
                id = textListItem.ॱ();
                String ˏ = textListItem.ˏ();
                if (id == 1) {
                    ˏ((Activity) view.getContext(), ˏ);
                }
            }
        }
    }

    private void ˏ(Activity activity, String str) {
        if (!dof.ॱ(str)) {
            try {
                activity.startActivity(new Intent(ACTION.HWID_SCHEME_URL, Uri.parse(str)));
            } catch (Exception e) {
                Logger.ˋ("DetailTextListCard", " There is no browser." + e.toString());
            }
        }
    }

    public void ॱ(chz o_chz) {
        super.ॱ(o_chz);
        if (this.ॱॱ != null && o_chz.ʻ() != null) {
            CSSView.wrap(this.ॱॱ, o_chz.ʻ()).render();
        }
    }
}
